//
//  YSAppConfig.m
//  YSKitExample
//
//  Created by Kyson on 2017/6/16.
//  Copyright © 2017年 YangShen. All rights reserved.
//

#import "YSAppConfig.h"

#define UserDefaults          [NSUserDefaults standardUserDefaults]

@implementation YSAppConfig

#pragma mark - Getter

// object
+ (void)ys_setObject:(id)value forKey:(NSString *)key {
    [UserDefaults setObject:value forKey:key];
    [UserDefaults synchronize];
}

+ (id)ys_objectForKey:(NSString *)key {
    return [UserDefaults objectForKey:key];
}

// string
+ (void)ys_setString:(id)value forKey:(NSString *)key {
    [UserDefaults setObject:value forKey:key];
    [UserDefaults synchronize];
}
+ (NSString *)ys_stringForKey:(NSString *)key {
    return [UserDefaults valueForKey:key] ? [UserDefaults valueForKey:key] : @"";
}

// float
+ (void)ys_setFloat:(float)value forKey:(NSString *)key {
    [UserDefaults setFloat:value forKey:key];
    [UserDefaults synchronize];
}

+ (float)ys_floatForKey:(NSString *)key {
    return [UserDefaults floatForKey:key];
}

// int
+ (void)ys_setInteger:(NSInteger)value forKey:(NSString *)key {
    [UserDefaults setInteger:value forKey:key];
    [UserDefaults synchronize];
}

+ (NSInteger)ys_integerForKey:(NSString *)key {
    return [UserDefaults integerForKey:key];
}

// bool
+ (void)ys_setBool:(BOOL)value forKey:(NSString *)key {
    [UserDefaults setBool:value forKey:key];
    [UserDefaults synchronize];
}

+ (BOOL)ys_boolForKey:(NSString *)key {
    return [UserDefaults boolForKey:key];
}

@end
